package acm.pta14;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.LinkedList;

public class 矩阵列平移 {
    public static void main(String[] args) {
        Reader sc = new Reader();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        LinkedList<Integer>[] list = new LinkedList[n];
        for (int i = 0; i < list.length; i++) {
            list[i] = new LinkedList<>();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                list[j].add(sc.nextInt());
            }
        }
        int pos = 1;
        for (int i = 1; i < list.length; i += 2) {
            if (pos > k) {
                pos = 1;
            }
            for (int j = 0; j < pos; j++) {
                list[i].addFirst(x);
                list[i].removeLast();
            }
            pos++;
        }
        StringBuilder builder= new StringBuilder();
        for (int i = 0; i < n; i++) {
            int res=0;
            for (int j = 0; j < n; j++) {
                res+=list[j].pollFirst();
            }
            builder.append(res).append(" ");
        }
        builder.deleteCharAt(builder.length()-1);
        System.out.println(builder);
    }

    static class Reader {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (Exception ignored) {}
            return (int) in.nval;
        }
    }
}
